Skip to content

Conversation

@AengusMcGuinness
Copy link
Contributor

Description:

This PR fixes an abort error that occurs when WTinyLFU is initialized with an empty parameter string (e.g., using the -e "" flag in the CLI).

The issue was located in cache_init.h, where the code attempted to append default parameters to the user input. When the input was empty, the code produced a malformed string with a leading comma: ",window-size=0.01"

Changes:

Updated the logic in bin/cachesim/cache_init.h to check if eviction_params is NULL or an empty string ("").

If empty, it now passes a clean default string ("window-size=0.01") without a leading comma.

This ensures the initialization sequence is syntactically correct for the internal parser.

Verification:

Command:

(libCacheSim) libCacheSim/_build (libCacheSim) % ./bin/cachesim ../data/cloudPhysicsIO.txt txt tinyLFU 100M -e ""

Before:

[ERROR] 01-21-2026 15:16:29 WTinyLFU.c:376  (tid=8514739968): WTinyLFU does not have parameter ,window-size                     

After:

[INFO]  01-21-2026 15:28:06 cli_parser.c:559  (tid=8514739968): trace path: ../data/cloudPhysicsIO.txt, trace_type PLAIN_TXT_TRA
CE, ofilepath result/cloudPhysicsIO.txt.cachesim, 12 threads, warmup -1 sec, total 1 algo x 1 size = 1 caches, tinyLFU, eviction
-params:                                                                                                                        
[DEBUG] 01-21-2026 15:28:06 request.h:128  (tid=8514739968): req clock_time 0, id 1, size 1, op nop, valid 1                    
[DEBUG] 01-21-2026 15:28:06 request.h:128  (tid=8514739968): req clock_time 0, id 2, size 1, op nop, valid 1                    
../data/cloudPhysicsIO.txt WTinyLFU-w0.01-SLRU cache size   100MiB,           113872 req, miss ratio 0.4301, throughput 0.21 MQPS ```

@gemini-code-assist
Copy link

Summary of Changes

Hello @AengusMcGuinness, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves a critical initialization crash in the WTinyLFU cache algorithm. Previously, providing an empty string for eviction parameters would lead to a malformed parameter string and an application abort. The changes ensure robust handling of empty or null eviction parameters by supplying a correct default, thereby preventing the crash and allowing the cache to initialize successfully.

Highlights

  • Fixes WTinyLFU Initialization Crash: Addresses an abort error that occurred when the WTinyLFU cache algorithm was initialized with empty eviction parameters.
  • Prevents Malformed Parameter String: Corrects an issue where an empty parameter input led to a syntactically incorrect string (e.g., ",window-size=0.01"), causing the initialization to fail.
  • Ensures Valid Default Parameters: Modifies the initialization logic to explicitly provide "window-size=0.01" as a default parameter when the provided eviction parameters are either NULL or an empty string.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request correctly fixes a crash that occurs when initializing WTinyLFU with empty eviction parameters. The change properly handles both NULL and empty string cases for eviction_params. I have one suggestion to make the code slightly cleaner by using NULL to rely on the default parameters defined within WTinyLFU_init, which improves clarity and maintainability.

Comment on lines 106 to 107
if (eviction_params == NULL || eviction_params[0] == '\0') {
cache = WTinyLFU_init(cc_params, "window-size=0.01");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

While this change correctly fixes the crash with empty parameters, passing NULL to WTinyLFU_init would be a cleaner way to apply the default parameters. The WTinyLFU_init function is already designed to use DEFAULT_PARAMS when its cache_specific_params argument is NULL. This approach avoids redundant parsing and makes the intention of using default values more explicit.

    if (eviction_params == NULL || eviction_params[0] == '\0') {
      cache = WTinyLFU_init(cc_params, NULL);

@1a1a11a
Copy link
Owner

1a1a11a commented Jan 21, 2026

Thank you!

@1a1a11a
Copy link
Owner

1a1a11a commented Jan 21, 2026

It looks like there is a failed check

@AengusMcGuinness
Copy link
Contributor Author

thank you for the heads-up! I've pushed a new commit that fixes the trailing whitespace issue in the clang-format check. I also took the suggestion from the code assistant to pass NULL to WTinyLFU_init for a cleaner implementation using internal defaults.

@1a1a11a 1a1a11a merged commit f249ad3 into 1a1a11a:develop Jan 22, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants